<!DOCTYPE html>
<html>
<head>
    <title>数据库文档</title>
    <meta charset="UTF-8">
    <style>
        body { font-family: Arial, sans-serif; margin: 20px; }
        .table { margin-bottom: 30px; border: 1px solid #ddd; padding: 15px; }
        .table-name { font-size: 18px; font-weight: bold; margin-bottom: 10px; }
        .column-table { width: 100%; border-collapse: collapse; }
        .column-table th, .column-table td { border: 1px solid #ddd; padding: 8px; text-align: left; }
        .column-table th { background-color: #f5f5f5; }
    </style>
</head>
<body>
    <h1>数据库文档</h1>
    <p>生成时间: ${generateTime!''}</p>
    
    <#if schema??>
        <#if schema.tables??>
            <#list schema.tables as table>
                <div class="table">
                    <div class="table-name">${table.name!''} <#if table.comment??> - ${table.comment}</#if></div>
                    <#if table.columns??>
                        <table class="column-table">
                            <thead>
                                <tr>
                                    <th>字段名</th>
                                    <th>类型</th>
                                    <th>是否为空</th>
                                    <th>默认值</th>
                                    <th>注释</th>
                                </tr>
                            </thead>
                            <tbody>
                                <#list table.columns as column>
                                    <tr>
                                        <td>${column.name!''} <#if column.primaryKey?? && column.primaryKey>🔑</#if></td>
                                        <td>${column.type!''}<#if column.size??>(${column.size}<#if column.decimalDigits?? && column.decimalDigits &gt; 0>,${column.decimalDigits}</#if>)</#if></td>
                                        <td>${(column.nullable!false)?string('是','否')}</td>
                                        <td>${column.defaultValue!''}</td>
                                        <td>${column.comment!''}</td>
                                    </tr>
                                </#list>
                            </tbody>
                        </table>
                    </#if>
                </div>
            </#list>
        </#if>
    </#if>
</body>
</html>